﻿using System.Windows;
using System.Windows.Input;

namespace CustomWindow
{
    /// <summary>
    /// Code behind for the custome window style
    /// </summary>
    partial class WindowStyle
    {
        /// <summary>
        /// Handler for dragging the Titlebar
        /// </summary>
        /// <param name="sender">event sender (titlebar)</param>
        /// <param name="args">mouse state</param>
        private void TitlebarMouseMove(object sender, MouseEventArgs args)
        {
            // only if left mouse is pressed
            if (args.LeftButton == MouseButtonState.Pressed)
            {
                // get handle to window (titlebar parent)
                Window win = (Window) ((FrameworkElement) sender).TemplatedParent;

                // move the window based on the drag
                win.DragMove();
            }
        }
    }
}
